const {aa,Op} = require("../model");


let list=async(ctx,next)=>{
let keyword=ctx.request.query.keyword;
let list = await aa.findAll({
    
    order:['id']
})
if (keyword) {
    list =await aa.findAll({
        where:{
            [Op.or]:[{
                id:isNaN(keyword) ? 0:parseFloat(keyword),
                bt:keyword,
                zy:keyword,
                ny:keyword,
                fl:keyword,
                zz:keyword
                
            }]
        }
       
      
    })

    
}
ctx.body=list
}



let deleted=async(ctx,next)=>{
let id=ctx.request.body.id
let dele= await aa.destroy({
    where:{
        id:id
    }
})
ctx.body=dele
}



let save=async(ctx,next)=>{
let obj =ctx.body
await aa.create(obj)
ctx.body=''
}




module.exports={
'get /blog':list,
'post /deleted':deleted,
'post /save':save,


}